<template>
	<el-drawer title="通知公告详情" v-model="visible" :size="800" destroy-on-close @closed="$emit('closed')">
		<el-container v-loading="loading">
			<el-main>
				<el-header style="display: block;text-align: center">
					<div style="text-align: center;display: inline;font-weight: 600;font-size: 16px">
						{{ form.noticeTitle }}
					</div>
				</el-header>
			<el-main>
				<span v-html="form.content"></span>
				<el-form-item label="相关附件" v-if="form.attachId!=''">
					<attach-menu :attachIds="form.attachId" :roleFlag="form.attachRole" :preview="true"></attach-menu>
				</el-form-item>
				<div style="margin-top: 20px;text-align: right;">
					<div style="float: left;">
						【{{form.noticeTypeName}}】{{form.createUser}}
					</div>
					<span>点击：{{form.onclickCount}}次</span><span style="margin-left: 20px">发布时间：{{form.sendTime}}</span>
				</div>
			</el-main>
				<el-footer style="text-align: center;">
					<el-button @click="visible=false">关闭</el-button>
				</el-footer>
			</el-main>
		</el-container>
	</el-drawer>
</template>

<script>
import AttachMenu from '@/views/module/attachMenu'
export default {
	name: 'Notice Details',
	components: {
		AttachMenu,
	},
	data() {
		return {
			form:{
				noticeId:'',
				noticeTitle: '',
				noticeType: '',
				isTop: '0',
				sendTime:'',
				endTime:'',
				templateType:'',
				attachRole:'1',
				content:'',
				msgType:'',
				attachId:''
			},
			model:"read",
			visible: false,
			isSaveing: false,
		}
	},
	mounted() {
	},
	methods:{
		open(model){
			this.model=model;
			this.visible = true;
			return this;
		},

		setData(data){
			this.form.noticeId=data.noticeId
			this.form.noticeTitle =data.noticeTitle
			this.form.noticeTypeName=data.noticeTypeName
			this.form.content = data.content
			this.form.sendTime = data.sendTime
			this.form.onclickCount=data.onclickCount
			this.form.createTime=data.createTime
			this.form.attachId = data.attachId
			this.form.endTime = data.endTime
			this.form.templateType = data.templateType
			this.form.attachRole = data.attachRole
			if(this.model!='setting')
			{
				this.setNoticeReadStatus(data.noticeId);
			}
		},
		async setNoticeReadStatus(noticeId){
			await this.$API.info.notice.setNoticeReadStatus.post({noticeId:noticeId});
		},
		async getMyNoticeById(data)
		{
			let res = await this.$API.info.notice.getMyNoticeById.get({noticeId:data});
			{
				if(res.code==200)
				{
					this.form.noticeId=res.data.noticeId
					this.form.noticeTitle =res.data.noticeTitle
					this.form.noticeTypeName=res.data.noticeTypeName
					this.form.content = res.data.content
					this.form.sendTime = res.data.sendTime
					this.form.onclickCount=res.data.onclickCount
					this.form.createTime=res.data.createTime
					this.form.attachId = res.data.attachId
					this.form.endTime = res.data.endTime
					this.form.templateType = res.data.templateType
					this.form.attachRole = res.data.attachRole
					this.setNoticeReadStatus(data);
				}else
				{
					this.$alert(res.message, "提示", {type: 'error'})
				}
			}
		}

	}

}
</script>

<style>
</style>
